; Dos file interface driver       /HJ
; ***********************************
;
; process description
; *******************
;
; a48:           <interval low>
; a49:           <interval high>
; a10:           <kind = 94>
; a11:           <name>
; a50:           <device number * 64>
; a52:           <reserved>
; a53:           <users>
; a54:           <next message>
; a55:           <last message>
; a56:           <interrupt address>
;

c. (:a81>16 a.1:)-1             ; if include then
                                ; begin

m.          Dos file driver
b. i50,r25
w.

a0=1<23
; operation and mode
     a0>0+a0>3+a0>5+13    ; operation 
i0:  a0>0+a0>2+a0>4      ; mode

i6:  r0,0,0,r3,0,r5,r20,r21,0,r23 ; jump table

; entry:
h51:  jl  w3  g15        ;   check reservation;
      dl. w1  i0.        ;
      jl  w3  g16        ;   check operation(0.3.5.20.21.23,0.2.4);
      jl  w3  g17        ;   link operation;

; start:
i1:   bz  w3  x2+8       ; load op.
      sl  w3  20
      al  w3  x3-14      ; if w3>20 then w3:=w3-14;
      wa  w3  6          ; w3+w3;
      am.     i6.
      jl.    (x3)        ; goto case op of ...

; sense:
r0: 
      la  w3  0
      rs  w3  g20        ; status:=0;
      jl. w3  g18        ; deliver result1
      jl.     i3         ; goto done1

; close:
r22:
      jl  w3  g31        ;   increase stopcount;
      am     (x1+a50)
      io      54         ; ctrl(close)
      sx      2.11       ;   if exception then
      jl.     i4.        ;    goto disconnected;

      jl  w3  c32        ; wait interrupt;  
      am      0
      io  w0 (x1+a50)    ;   sense(device,status);
      sx      2.11       ;   if exception then
      jl.     i4.        ;    goto disconnected;
      rs  w0  g20        ;   save status;
      jl. w3  g18        ; deliver result1
      jl  w3  g32        ;   decrease stopcount;
      jl.     i3         ; goto done1

; input:
r3:   am     (13-17)
; output:
r5:   am     (17-45)
; open_in:
r21:  am     (45-49)
; open_out:
      al  w0  49

      jl  w3  g31        ;   increase stopcount;
      rl  w3  x2+12      ; w3:=last;
      ws  w3  x2+10      ; w3:=first; (first,last made even by check_operation)
      am     (x1+a50)
      io  w3  9          ; ctrl(transfer size)
      sx      2.11       ;   if exception then
      jl.     i4.        ;    goto disconnected;

      rl  w3  x2+10      ; w3:=first;
      am     (x1+a50)
      io  w3 (0)         ; ctrl(op)
      sx      2.11       ;   if exception then
      jl.     i4.        ;    goto disconnected;

      jl  w3  c32        ; wait interrupt;  
      am      0
      io  w0 (x1+a50)    ;   sense(device,status);
      sx      2.11       ;   if exception then
      jl.     i4.        ;    goto disconnected;
      rs  w0  g20        ;   save status;

      am      4
      io  w3 (x1+a50)    ;   sense4(device,status);
      sx      2.11       ;   if exception then
      jl.     i4.        ;    goto disconnected;
      rs  w3  g22        ;   save chars;
      al  w3  x3+2
      al  w0  0
      wd. w3  i5.
      wa  w3  6
      rs  w3  g21        ;   bytes:=(chars+2)//3*2;

      rl  w0  g20        ; w0:=status;
      bz  w3  x2+8
      sn  w0  0
      sh  w3  20
      jl.     i2.        ; if op<>open_xx or status<>0 then goto done0;

      bz  w3  x2+9       ;  w3:=mode;
      am     (x1+a50)
      io  w3  5          ; ctrl(set mode)
      sx      2.11       ;   if exception then
      jl.     i4.        ;    goto disconnected;

; done0:
i2:   jl  w3  g32        ;   decrease stopcount;
      jl  w3  g18        ;   deliver result(1);

; done1:
i3:   jl  w3  g25        ;   next operation;
      jl.     i1.        ;   goto start;

; disconnected:
i4:   jl  w3  g32        ;   decrease stopcount;
      jl  w3  g29        ;   disconnected device;
      jl.     i3.        ;   goto done1;

i5:  3   ; chars per word

e.   ; end of dos file driver
z. h51=g3 ; goto result5

n.                       ; return to rc monitor text
c. (: (:a81>18 a.1:) o. (:a81>17 a.1:) :)-1 ;  if include private
                                            ;   process descriptions then
                                            ;   begin



